package com.agan.agangame.service.impl;

import java.util.concurrent.ThreadLocalRandom;

import com.agan.agangame.dao.CiyuDao;
import com.agan.agangame.entity.CiyuEntity;
import com.agan.agangame.service.CiyuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("ciyuService")
@Slf4j
public class CiyuServiceImpl extends ServiceImpl<CiyuDao, CiyuEntity> implements CiyuService {

    @Autowired
    private CiyuDao ciyuDao;

    @Override
    public CiyuEntity queryPage() {
       int  maxId = ciyuDao.getMaxId();

        // start <= number < end
        int start = 1;
        int randomNum = ThreadLocalRandom.current().nextInt(start, maxId );
        log.info("随机数：{}",randomNum);

        CiyuEntity ciyuEntity = ciyuDao.selectById(randomNum);
        log.info("随机数：{},随机数：{}",randomNum,ciyuEntity);
        return ciyuEntity;
    }

}